﻿@{
    ViewBag.Title = "班级信息";
}
@section header{

}
<partial name="_page_list" />

@section scripts{
    <script>
        var baseUrl = "/School/Classes/";
        $(function () {
            gridList();
        })
        function gridList() {
            var $gridList = $("#gridList");
            $gridList.dataGrid({
                url: baseUrl + "GetJGridPageDataJson",
                datatype: "json",
                height: $(window).height() - 120,
                mtype: "POST",
                colModel: [
                    { label: "主键", name: "ID", hidden: true, key: true },
                    { label: '所属校区', name: 'SchoolAreaId', align: 'left' },
                    { label: '所属院系', name: 'Colleges', align: 'left' },
                    { label: '班级名称', name: 'Name', align: 'left' },
                    { label: '入学年份', name: 'EnrollmentYear', align: 'left' },
                    { label: '专业', name: 'Major', align: 'left' },
                    { label: '班级人数', name: 'NumberPeople', align: 'left' },
                    { label: '固定教学楼', name: 'TeachingBuilding', align: 'left' },
                    { label: '固定教室', name: 'ClassRoom', align: 'left' },
                    { label: '添加时间', name: 'AddTime', align: 'left' }
                ],
                rowNum: 20,
                rowList: [20, 50, 100],
                pager: '#gridPager',
                sortname: 'OrderBy',
                sortorder: "asc",
                viewrecords: true,
                autowidth: true,
                multiselect: true,
                loadComplete: function () {
                    $('.ui-jqgrid-bdiv').scrollTop(0);
                    setTimeout(function () { btn_tc(); });
                }
            });
            $("#btn_search").click(function () {
                $gridList.jqGrid('setGridParam', {
                    postData: { keyword: $("#txt_keyword").val() },
                }).trigger('reloadGrid');
            });
        }
        function btn_add() {
            $.modalOpen({
                id: "Form",
                title: "新增",
                url: baseUrl + "Form",
                width: "700px",
                height: "440px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        }
        function btn_edit() {
            var keyValue = $("#gridList").jqGridRowValue().ID;
            $.modalOpen({
                id: "Form",
                title: "修改",
                url: baseUrl + "Form?keyValue=" + keyValue,
                width: "700px",
                height: "440px",
                callBack: function (iframeId) {
                    top.frames[iframeId].submitForm();
                }
            });
        }
        function btn_delete() {
            $.deleteForm({
                url: baseUrl + "DeleteForm",
                param: { keyValue: $("#gridList").jqGridRowValue().ID },
                success: function () {
                    $.currentWindow().$("#gridList").resetSelection();
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                }
            })
        }
        function btn_details() {
            var keyValue = $("#gridList").jqGridRowValue().ID;
            $.modalOpen({
                id: "Details",
                title: "查看",
                url: baseUrl + "Details?keyValue=" + keyValue,
                width: "700px",
                height: "490px",
                btn: null,
            });
        }
    </script>
}